package com.itgacl.magic4j.libcommon.component.delayQueue.scheduler;


import com.itgacl.magic4j.libcommon.component.delayQueue.service.AutoPollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 自动作业
 *
 */
@EnableScheduling
@Configuration
public class AutoPollScheduler {

    /**
     * 自动出队列消息
     */
    @Autowired
    private AutoPollService autoPollService;

    /**
     * 整理压缩
     */
    @Scheduled(fixedRate = 24 * 60 * 60 * 1000)
    public void compact() {
        autoPollService.compact();
    }

    /**
     * 清理超时消息
     */
    @Scheduled(fixedRate = 50)//上一次开始执行时间点之后1秒再执行
    public void clearTimeoutMessage() {
        autoPollService.sendDelayMessage();
    }
}
